import React, { Component } from "react";
import { Switch, Route, Redirect, Link } from "react-router-dom";
import { Menu } from "antd";
import home from "./home";
import mydata from "./Mydata";
import projectdetail from "./projectdetail";
import datadetail from "./datadetail";

class project extends Component {
  constructor(props) {
    super(props);
    this.state = {
      current: "1",
    };
  }
  handleClick = (e) => {
    console.log("click ", e);
    this.setState({
      current: e.key,
    });
  };
  render() {
    return (
      <div>
        <Menu
          className="nav"
          onClick={this.handleClick}
          selectedKeys={[this.state.current]}
          mode="horizontal"
        >
          <Menu.Item key="1">
            <Link to="/project">我的项目</Link>
          </Menu.Item>
          <Menu.Item key="2">
            <Link to="/project/mydata">我的数据</Link>
          </Menu.Item>
        </Menu>
        <Switch>
          <Route path="/project" component={home} exact />
          <Route path="/project/mydata" component={mydata} />
          <Route path="/project/projectdetail" component={projectdetail} />
          <Route path="/project/datadetail" component={datadetail} />

          <Redirect to="/project" />
        </Switch>
      </div>
    );
  }
}

export default project;
